package com.swg.cocobox.filetransfer.internal;

import java.nio.charset.Charset;

import com.swg.cocobox.filetransfer.command.ClientCommand;

final class ClientCommandImpl implements ClientCommand{
	private static final long serialVersionUID = 8919205736703393944L;

	private final String commandCode;
	private final String message;
	private final Charset encoding;
	
	public ClientCommandImpl(final Charset encoding,final String commandCode,final String message) {
		this.commandCode=commandCode;
		this.message=message;
		this.encoding=encoding;
	}
	
	@Override
	public String getCommandCode() {
		return commandCode;
	}

	@Override
	public String getMessage() {
		return message;
	}

	@Override
	public byte[] getBytes() {
		byte[] data=null;
		String commands=null;
		StringBuilder builder=new StringBuilder();
		builder.append(commandCode);
		builder.append(" ");
		builder.append(message);
		commands=new String(builder.toString());
		data=commands.getBytes(encoding);
		return data;
	}

	@Override
	public String toString() {
		return "ClientCommand [commandCode=" + commandCode + ", message="
				+ message + "]";
	}
	
	

}
